<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="../../lib/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../lib/layui/css/layui.css" />

		<link rel="stylesheet" href="layui/css/layui.css" media="all">
		<link rel="stylesheet" type="text/css" href="lib/layui/css/layui.css" media="all" />
	</head>

	<body>

		<div class="layuimini-container">
			<div class="layuimini-main">
				<fieldset class="table-search-fieldset">
					<legend>搜索信息</legend>
					<div style="margin: 10px 10px 10px 10px">
						<!--搜索框-->
						<div class="layui-form-item">
							<label class="layui-form-label">采购计划单</label>
							<div class="layui-input-inline">
								<input type="text" name="purchasingplanId" id="purchasingplanId" placeholder="请输入标题"
									autocomplete="off" class="layui-input">
							</div>
							<label class="layui-form-label">计划人</label>
							<div class="layui-input-inline">
								<input type="text" name="planerId" id="planerId" placeholder="请输入标题" autocomplete="off"
									class="layui-input">
							</div>
							<label class="layui-form-label">审核者</label>
							<div class="layui-input-inline">
								<input type="text" name="uname" id="uname" placeholder="请输入标题" autocomplete="off"
									class="layui-input">
							</div>
							<div class="layui-input-inline">
								<button class="layui-btn" lay-submit lay-filter="formDemo">检索</button>
							</div>
						</div>
					</div>
				</fieldset>
				<table class="layui-hide" id="test" lay-filter="test"></table>

				<script type="text/html" id="switchTpl">
					<input type="checkbox" style="width:30px;" name="IsLockout" id="IsLockout" value="{{d.id}}" lay-skin="switch"
						lay-text="开启|禁用" lay-filter="sexDemo" {{ d.isLockout==0 ? 'checked' : '' }}>
				</script>

				<script type="textml" id="toolbarDemo">

				</script>

			</div>
		</div>
		<table id="demo" lay-filter="test"></table>

		<script src="../../layui/layui.js"></script>
		<script src="../../js/User.js" type="text/javascript" charset="utf-8"></script>
		<script>
			layui.use(['table', 'form'], function() {
				var table = layui.table;
				var $ = layui.$;
				var form = layui.form;
				//第一个实例
				table.render({
					elem: '#demo',
					height: 312,
					url: globalData.server + 'Purder/getAllPurder',
					page: true,
					cols: [
						[ //表头
							{
								field: 'purchaseorder_id',
								title: '采购订单单号',
								width: 155,
								sort: true,
								fixed: 'left'
							}, {
								field: 'supplier_id',
								title: '供应商',
								width: 100
							}, {
								field: 'order_date',
								title: '订单日期',
								width: 250,
								templet: "<div>{{!d.order_date?'':layui.util.toDateString(d.order_date,'yyyy-MM-dd HH:mm:ss')}}</div>"
							}, {
								field: 'delivery_date',
								title: '交货日期',
								width: 100,
								templet: "<div>{{!delivery_date?'':layui.util.toDateString(delivery_date,'yyyy-MM-dd HH:mm:ss')}}</div>"
							}, {
								field: 'currency',
								title: '货币',
								width: 100
							}, {
								field: 'purchase_id',
								title: '采购人',
								width: 100,
								templet: "<div>{{!d.create_date?'':layui.util.toDateString(d.create_date,'yyyy-MM-dd HH:mm:ss')}}</div>"
							}, {
								field: 'trading_locations',
								title: '交货地点',
								width: 100
							}, {
								field: 'remarks',
								title: '备注',
								width: 100
							}, {
								field: 'operator_id',
								title: '操作员',
								width: 100
							}, {
								field: 'inspector_id',
								title: '审核者',
								width: 100
							}, {
								field: 'inspector_status',
								title: '审核状态',
								width: 100
							}, {
								field: 'if_finish',
								title: '是否完成',
								width: 100
							}

							/* //里的toolbar值是模板元素的选择器 */

						]
					]
				});
				$.getJSON("/Pur/getAllPur", function(obj) {
					if (obj.count > 0) {
						for (var i = 0; i < obj.data.length; i++) {
							$("#purchasingplanId").append(
								new Option(obj.data[i].handleId,
									obj.data[i].alarmDate))
						}
						form.render('select');
					}

				})
				//监听搜索
				form.on('submit(formDemo)', function(data) {
					//上述方法等价于
					table.reload('demo', {
						where: { //设定异步数据接口的额外参数，任意设
							purchasingplanId: data.field.purchasingplanId,
							planerId: data.field.planerId,
							uname: data.field.uname
						}
					}); //只重载数据
					return false;
				});
			});
		</script>
	</body>

</html>
